Am i passing values or adresses? [Java]

Posted by Samuel on Stack Overflow See other posts from Stack Overflow or by Samuel
Published on 2010-04-29T10:06:44Z Indexed on 2010/04/29 10:17 UTC
Read the original article Hit count: 633

Filed under:
|

Hello World,

I am new to java and i was asking myself, if i have a class 'Example' and somewhere i make a:

Example example1 = new Example();

and i add some stuff to it, lets say example1.setExampleBoolean(false); and now i make:

Example example2 = example1;
example2.setExampleBoolean(true);

Did i say with Example example2 = example1 let example2 point to the same adress as example1? Because than i would have altered example1.

In other words would, using something like:

Boolean exampleBoolean = example1.getExampleBoolean();

exampleBoolean be true of false?

Might be a stupid questions but for me it would change the way i'd handle problems in my programs :)

Thanks in advance

-Samuel

© Stack Overflow or respective owner

Related posts about java

Related posts about pointers